# Maintainer: Andy Postnikov <apostnikov@gmail.com>
pkgname=php8-pecl-datadog_trace
_extname=datadog_trace
_realname=ddtrace
pkgver=0.62.1
pkgrel=0
pkgdesc="APM and distributed tracing for PHP 8 - PECL"
url="https://pecl.php.net/package/datadog_trace"
arch="all !x86 !armv7 !armhf" # 64 bits only
license="BSD-3-Clause"
depends="php8-common"
makedepends="php8-dev curl-dev"
checkdepends="php8-cgi php8-curl php8-session"
source="php-pecl-$_extname-$pkgver.tgz::https://pecl.php.net/get/$_extname-$pkgver.tgz
	fix-cgi-test.patch"
builddir="$srcdir/$_extname-$pkgver"

build() {
	phpize8
	./configure --prefix=/usr --with-php-config=php-config8
	make
}

check() {
	local _modules=/usr/lib/php8/modules
	make NO_INTERACTION=1 REPORT_EXIT_STATUS=1 test \
		PHP_TEST_SHARED_EXTENSIONS=" \
		-d extension=$_modules/curl.so \
		-d extension=$_modules/session.so \
		-d extension=modules/$_realname.so" \
		TEST_PHP_CGI_EXECUTABLE=/usr/bin/php-cgi8 \
		TESTS='--show-diff'
}

package() {
	make INSTALL_ROOT="$pkgdir" install
	local _confdir="$pkgdir"/etc/php8/conf.d
	install -d $_confdir
	echo "extension=$_realname" > $_confdir/$_extname.ini
}

sha512sums="
f1cbf97c390781682b95779c0fc08791ad1f0e6019fa3faee27a79db834e6a3838a88b9508082f7481419996e574b3fc947cb1fb9d944e28cbf77515a91bee3c  php-pecl-datadog_trace-0.62.1.tgz
4a17d92ae1c495b0acc1f16d1732e33dd82f7b182adae83f7278b710c2c5f1c8e56471b2d2b4545992c01cc57e3eae19bbfd09dae3d389fb9d7efcdd9b3ab8cc  fix-cgi-test.patch
"
